package com.smart.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smart.common.annotation.Log;
import com.smart.common.core.controller.BaseController;
import com.smart.common.core.domain.AjaxResult;
import com.smart.common.enums.BusinessType;
import com.smart.manage.domain.DrugOrders;
import com.smart.manage.service.IDrugOrdersService;
import com.smart.common.utils.poi.ExcelUtil;
import com.smart.common.core.page.TableDataInfo;

/**
 * 药品订单管理Controller
 * 
 * @author lingyao
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/manage/drugOrders")
public class DrugOrdersController extends BaseController
{
    @Autowired
    private IDrugOrdersService drugOrdersService;

    /**
     * 查询药品订单管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:drugOrders:list')")
    @GetMapping("/list")
    public TableDataInfo list(DrugOrders drugOrders)
    {
        startPage();
        List<DrugOrders> list = drugOrdersService.selectDrugOrdersList(drugOrders);
        return getDataTable(list);
    }

    /**
     * 导出药品订单管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:drugOrders:export')")
    @Log(title = "药品订单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DrugOrders drugOrders)
    {
        List<DrugOrders> list = drugOrdersService.selectDrugOrdersList(drugOrders);
        ExcelUtil<DrugOrders> util = new ExcelUtil<DrugOrders>(DrugOrders.class);
        util.exportExcel(response, list, "药品订单管理数据");
    }

    /**
     * 获取药品订单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:drugOrders:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return success(drugOrdersService.selectDrugOrdersByOrderId(orderId));
    }

    /**
     * 新增药品订单管理
     */
    @PreAuthorize("@ss.hasPermi('manage:drugOrders:add')")
    @Log(title = "药品订单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DrugOrders drugOrders)
    {
        return toAjax(drugOrdersService.insertDrugOrders(drugOrders));
    }

    /**
     * 修改药品订单管理
     */
    @PreAuthorize("@ss.hasPermi('manage:drugOrders:edit')")
    @Log(title = "药品订单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DrugOrders drugOrders)
    {
        return toAjax(drugOrdersService.updateDrugOrders(drugOrders));
    }

    /**
     * 删除药品订单管理
     */
    @PreAuthorize("@ss.hasPermi('manage:drugOrders:remove')")
    @Log(title = "药品订单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(drugOrdersService.deleteDrugOrdersByOrderIds(orderIds));
    }
}
